<?php
namespace app\admin\model;
use app\admin\BaseModel;
use think\facade\Db;
use think\facade\Request;
use think\model\concern\SoftDelete;

class Order extends BaseModel
{
    use SoftDelete;
    protected $deleteTime = 'delete_time';
    public function searchStatusAttr($q,$v,$d)
    {
        $q->where('status','=',$v);
    }
    public function searchKeywordsAttr($q,$v,$d)
    {
        $q->where('aname','like',"%$v%");
    }
    public static function getOrderList($where)
    {

        $list=self::alias("a")
        ->field("a.id,a.aname,a.price,a.status,a.amount,a.addtime,a.remark,b.order_status  sname")
            ->where('delete_time','=',null)
            ->join('order_status b',"a.status=b.status_id","left")
            ->withSearch(array_keys($where),$where)->paginate([
            'list_rows'=>5,
            'query'=>request()->param()
        ]);
        return $list;
    }
}